package com.lineage.server.model.weaponskill;

import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.L1Character;
import java.util.Random;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class W_SK003 extends L1WeaponSkillType {
  private static final Log _log = LogFactory.getLog(W_SK003.class);
  
  private static final Random _random = new Random();
  
  public static L1WeaponSkillType get() {
    return new W_SK003();
  }
  
  public double start_weapon_skill(L1PcInstance pc, L1Character target, L1ItemInstance weapon, double srcdmg) {
    try {
      int chance = _random.nextInt(1000);
      int random = random(weapon);
      if (random >= chance) {
        int hpadd = Math.max((int)(srcdmg * this._type1 / this._type2), 1);
        short newHp = (short)(pc.getCurrentHp() + hpadd);
        pc.setCurrentHp(newHp);
        return 0.0D;
      } 
      return 0.0D;
    } catch (Exception e) {
      _log.error(e.getLocalizedMessage(), e);
      return 0.0D;
    } 
  }
}
